﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using ViewMaker;

namespace CloudStorageLight.DesktopTool
{
    public class MainVM : ViewModelBase
    {
        public string RootUrl { get; set; }
        public string SelectedFolder { get; set; }

        public string CurrentPath { get; set; }

        public string LoginUser { get; set; }

        public string LoginPassword { get; set; }

        public ICommand UploadCommand
        {
            get { return CreateCommand(UploadAction); }
        }
        private void UploadAction()
        {
            var util = new CloudStorageLightClient(RootUrl, LoginUser, LoginPassword);
            
            var dire = new DirectoryInfo(SelectedFolder);
            foreach (var file in dire.GetFiles())
            {
                try
                {
                    util.UploadAsImage(CurrentPath, file.FullName);
                    
                } 
                catch(Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
            }

        }
    }
}
